package thread;

import java.util.concurrent.locks.ReentrantLock;
//视频不完整，推测得出

public class Demo30 {
    public static Object locker1 = new Object();
    public static Object locker2 = new Object();
    public static Object locker3 = new Object();

    public static void main(String[] args) {


        Thread t1 = new Thread(()->{

            for (int i = 0; i < 10; i++) {
                synchronized (locker1) {

                    try {
                        locker1.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                System.out.println("A");
                synchronized (locker2) {
                    locker2.notify();

                }
            }

        });
        Thread t2 = new Thread(()->{

            for (int i = 0; i < 10; i++) {
                synchronized (locker2) {

                    try {
                        locker2.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                System.out.println("B");
                synchronized (locker3) {
                    locker3.notify();

                }
            }

        });
        Thread t3 = new Thread(()->{

            for (int i = 0; i < 10; i++) {
                synchronized (locker3) {

                    try {
                        locker3.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                System.out.println("C");
                synchronized (locker1) {
                    locker1.notify();

                }
            }

        });
        t1.start();
        t2.start();
        t3.start();




    }
}
